using System.ComponentModel;
using System.Drawing;
using System.Xml.Serialization;
using CodeSnippet.Options;
using CodeSnippet.Properties;

namespace CodeSnippet.Config
{
    /// <summary>
    /// Implementation of formatting properties.
    /// </summary>
    [DefaultProperty("SectionName")]
    public class EditorConfig : IEditorConfig, IConfigSection
    {
        #region Properties
        /// <summary>
        /// Gets the name of the section.
        /// </summary>
        /// <value>The name of the section.</value>
        [LocalizedCategory("CategoryAttribute_Attributes"), LocalizedDisplayName("DisplayNameAttribute_SectionName"), LocalizedDescription("DescriptionAttribute_SectionName"), XmlIgnore]
        public string SectionName
        {
            get { return Resources.ConfigSectionName_Editor; }
        }
        /// <summary>
        /// Gets the image.
        /// </summary>
        /// <value>The image.</value>
        [Browsable(false), XmlIgnore]
        public Bitmap Image
        {
            get { return Resources.editor; }
        }
        /// <summary>
        /// Number of space characters to substitute for tab characters. Default is <c>4</c>.
        /// </summary>
        [Category("Format"), LocalizedDisplayName("DisplayNameAttribute_TabSpaces"), LocalizedDescription("DescriptionAttribute_TabSpaces")]
        public byte TabSpaces { get; set; }
        /// <summary>
        /// Flag indicating whether or not to trim TAB characters from the beginning of lines when being pasted.
        /// </summary>
        [Category("Format"), LocalizedDisplayName("DisplayNameAttribute_TrimIndentOnPaste"), LocalizedDescription("DescriptionAttribute_TrimIndentOnPaste")]
        public bool TrimIndentOnPaste { get; set; }
        /// <summary>
        /// Flag indicating whether word-wrapping is enabled in the view.
        /// </summary>
        [Category("Format"), LocalizedDisplayName("DisplayNameAttribute_WordWrap"), LocalizedDescription("DescriptionAttribute_WordWrap")]
        public bool WordWrap { get; set; }
        #endregion Properties

        #region Initialization
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorConfig"/> class.
        /// </summary>
        public EditorConfig()
        {
            TabSpaces = 4;
            TrimIndentOnPaste = true;
            WordWrap = false;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorConfig"/> class.
        /// </summary>
        /// The <see cref="EditorConfig"/> instance from which to copy.
        public EditorConfig(IEditorConfig copy)
        {
            TabSpaces = copy.TabSpaces;
            TrimIndentOnPaste = copy.TrimIndentOnPaste;
            WordWrap = copy.WordWrap;
        }
        #endregion Initialization
    }
}